import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class BalaN here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class BalaN extends Actor
{
    private int numGolpes=0;
     private int x=0;
     private Actor colicionL; 
    /**
     * Act - do whatever the BalaN wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
        move(10);
         efecto();
         checa();
    }
    
    /**
    * metodo en el que se realiza la creacion del objeto turbe
    */
     private void efecto()
     {
       getWorld().addObject(new Turbe(),getX()-25,getY());
      
     }
     public void movimiento()
     {   
       World w=getWorld();  
       if(11>x)
       {
        setLocation(getX()-1,getY());
        x++;
      }  
        
      Actor d =getOneIntersectingObject(BalaN.class);
        if(d!=null)
        {
         w.removeObject(d);
        }
    }    
    
     public int regresaDano()
    {
      return(numGolpes);
    }  
     public void dano()
    {
     numGolpes--;   
    }     
    
    public void checa()
    {
        int x=super.getX();
        World mundo=super.getWorld();
        int ancho=mundo.getWidth();
        colicionL = getOneIntersectingObject(Ladron.class);
         int d=((Mundo)mundo).dameDano();
        if (colicionL != null)
        {
          
            Greenfoot.playSound("ooh.mp3");
           
            ((Mundo)mundo).cambiaDano(d-10);
           mundo.removeObject(this);
        }
        else{
        
             if(x>=ancho-1)
             mundo.removeObject(this);
     
              if(x<=1)
              {
                 mundo.removeObject(this);  
              }
        }
    }
}

